package com.tianpengtech.common.mock.impl.string;



import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.tianpengtech.common.mock.impl.AbstractNumberMock;
import com.tianpengtech.common.mock.impl.AbstractStringMock;
import com.tianpengtech.common.mock.impl.numberic.IntegerMock;
import com.tianpengtech.common.util.EngineUtil;

public class ChineseContentMock extends AbstractStringMock{

	private String file ;
	public ChineseContentMock(String file){
		this.file = file;
	}
	@Override
	public String mockData() {
		String content = EngineUtil.readFileContent(file,null);
		Document doc = Jsoup.parse(content);
		Elements elements =  doc.select("div>p");
		AbstractNumberMock<Integer> imock = new IntegerMock();
		
		int index = imock.mockData(0, elements.size());
		String descript="";
		if(index<elements.size()){
			Element e = elements.get(index);
			descript = e.text();
		}
		return descript;
	}

}
